 /**
  * 操作权限处理
  * Copyright (c) 2019 ruoyi
  */

 import store from '@/store'

 export default {
   inserted(el, binding, vnode) {

     const {
       value
     } = binding

     //const admin = store.getters && store.getters.admin;
     if (value == '') return true;
     const permissions = store.getters && store.getters.permissions_btnList

     if (permissions && permissions.length > 0 && value && value instanceof Array && value.length > 0) {
       const permissionFlag = value

       let hasPermissions = false;

       let exist = permissions.find(item => (permissionFlag.indexOf(item) > -1));
       if (exist) {
         hasPermissions = true;
       }

       if (!hasPermissions) {
         console.log('没权限')
         // el.parentNode && el.parentNode.removeChild(el)
       } else {
         console.log('有权限')
       }
     } else {
       //throw new Error(`请设置操作权限标签值`)
       // el.parentNode && el.parentNode.removeChild(el)
     }
   }
 }
